package models.vos.project {
	import business.MiscUtil;
	
	import models.vos.core.Task;
	
	import mx.collections.ArrayCollection;
	

	public class MajorTask extends Task {
		
		public var unitTasks:ArrayCollection = new ArrayCollection();
		public var group:MajorTaskGroup;
		
		public var members:ArrayCollection;
		public var objectives:ArrayCollection;
		
		//Display Const	
		public static const TASK_NAME_ONLY:int = 0;
		public static const TASK_NAME_CODE:int = 1;
		public static const TASK_NAME_CODE_DATE:int = 2;
		public static const TASK_NAME_CODE_OWNERS:int = 3;
		
		public function get accountableMem():MajorTaskOwner{
			if (members != null){
				for each (var m:MajorTaskOwner in members ){
					if( m.role == TaskRoles.ACCOUNTABLE ){
						return m;
					}
				}
			}
			return new MajorTaskOwner();
		}
		public function getSummaryString(detailMode:int):String{
			var res:String = '';
			if( detailMode != MajorTask.TASK_NAME_ONLY ){
				 res += '['+ this.code + '] ';
			}			
			if( detailMode == MajorTask.TASK_NAME_CODE_OWNERS && this.members != null && this.members.length > 0 ){
				res += '['+ this.accountableMem.nickname + '] ';
			};		
			if( detailMode == MajorTask.TASK_NAME_CODE_DATE && this.startDate != null && this.targetDate != false ){
				res += '[' + MiscUtil.formatDate(this.startDate, 'MM/DD') + '-' + 
							MiscUtil.formatDate(this.targetDate, 'MM/DD') + '] ';
			};			
			res += MiscUtil.properTrim( this.name, 80 );
			return res;
		}
		private var _dotString:String = ""; 
		
		public function getOwnersMappings():Array{
			return [];
		}
		public function getObjectivesMappings():Array{
			return [];
		}
		
		
		public function MajorTask(
			name:String = "", 
			code:String = "",
			startDate:Date = null, 
			targetDate:Date = null,
			members:ArrayCollection = null,
			objectives:ArrayCollection = null,
			id:Number = 0) {
				super(name, startDate, targetDate, id);
				this.code = code;
				this.members = (members == null ? new ArrayCollection() : members);
				this.objectives = (objectives == null ? new ArrayCollection() : objectives);
				
		}
		
		

	} // end class
} // end package